import {getPhone as getphone} from '@/store/api.js'
/*
微信登录
	返回 code
*/
export const wxlogin = ()=> {
	return new Promise((resolve, reject)=>{
		uni.showLoading({
		  title: '登录中...'
		});
		
		uni.login({
			provider: 'weixin',
			success: function(loginRes) {
				resolve(loginRes.code);
				uni.hideLoading();
			},
			fail(err) {
				reject(err)
				uni.hideLoading();
			}
		})
		
	})
}
/*
获取微信用户手机号 要先调用登录接口
	参数:obj{
		sessionkey,
		ivdata,
		encrypdata
	}
	返回手机号相关信息
	
*/
export const getPhone = (obj)=>{
	return new Promise((resolve, reject)=>{
		getphone(obj).then(res=>{
			resolve(JSON.parse(res.data.data.phone))
		},err=>{
			reject(err)
		})
	})
}